//
//  Teacher.m
//  解档归档存储数据
//
//  Created by 伍银荣 on 2021/6/28.
//  Copyright © 2021 com.example. All rights reserved.
//

#import "Teacher.h"

@implementation Teacher

+(BOOL)supportsSecureCoding {
    return YES;
}

-(void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:_name forKey:@"name"];
    [aCoder encodeInt:_age forKey:@"age"];
}


//只要有文件解析都会执行这个方法
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super init]) {
        _name = [aDecoder decodeObjectForKey:@"name"];
        _age = [aDecoder decodeIntForKey:@"age"];
    }
    return self;
}

@end
